@extends("admin.layout.main")

@section("content")
    <style>
        table thead tr th {
            text-align: center
        }

        table tbody tr td {
            text-align: center
        }
    </style>
    <form class="page-header">
        <h1>
            角色管理
        </h1>
    </form>
    <div class="page-header">
        <a href="{{ route('admin.platform.addPosition') }}" class="btn btn-xs btn-primary">新增角色</a>
    </div>
    <div>
        <table id="" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>序号</th>
                <th>角色名称</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            @foreach($data as $v)
                <tr>
                    <td>{{ $v->id }}</td>
                    <td>{{ $v->name }}</td>
                    <td>
                        @if($v->id!=1)
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="btn btn-xs btn-primary"
                                   href="{{ route('admin.platform.editPosition',['id'=>$v->id]) }}">查看</a>
                                <a class="btn btn-xs btn-danger" data-id="{{ $v->id }}"
                                   onclick="confirm_handle('确认删除吗？',del,'',this);">删除</a>
                            </div>
                            <div class="hidden-md hidden-lg">
                                <div class="inline pos-rel">
                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown"
                                            data-position="auto">
                                        <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                    </button>

                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li>
                                            <a href="{{ route('admin.platform.editPosition',['id'=>$v->id]) }}"
                                               class="tooltip-error" data-rel="tooltip" title="查看">
                                        <span class="blue">
                                            查看
                                        </span>
                                            </a>
                                        </li>
                                        <li>
                                            <a onclick="confirm_handle('确认删除吗？',del,'',this);" data-id="{{ $v->id }}"
                                               class="tooltip-info" data-rel="tooltip" title="删除">
                                        <span class="red">
                                            删除
                                        </span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        @endif
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div class="pagination pagination-centered">
            {{ $data->links('admin.layout.page') }}
        </div>
    </div>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
    <script>
        function del(obj) {
            var id = $(obj).data("id");
            var data = {'id': id};
            var url = '{{ route('admin.platform.ajaxDelPosition') }}';
            ajaxRequest(data, url, 'post');
        }
    </script>
@endsection